import pytest
from Auto.config.contest import Config
from Auto.utils import exce
from Auto.utils.utils import *
from Auto.utils.mysql import *
def test_excel():
    exce_path=r'C:\Users\30347\PycharmProjects\pythonProject6\Auto\data\hj.xlsx'
    Sheet_name='Sheet1'
    aaa=exce.read_excel(exce_path,Sheet_name)
    print(aaa)

@pytest.fixture(scope="module")
def api():
    return A3mall_login

@pytest.fixture
def db():
    db_mysql=MySql(host='10.59.9.12',user='root',password='yidong666',database='a3mall')
    yield db_mysql
    db_mysql.close()
@pytest.fixture(scope="module")
def token(api):
    login_data={
      "username": "13811033962",
      "password": "123456"
    }
    http=A3mall_login(url='http://10.59.9.14:7003/')
    res=http.post('api/public/login',json=login_data)
    tk=res.json()['data']['token']
    token=f'Bearer {tk}'
    return token
def test_a3mall_login():
    login_data={
        "username": "13811033962",
        "password": "123456"
    }
    http=A3mall_login(url='http://10.59.9.14:7003/')
    res=http.post('api/public/login',json=login_data)
    print(res.json())
def test_ms(token):
    body={
        "page" : 1,
        "sort" : 1
    }
    http=A3mall_login(url='http://10.59.9.14:7003/')
    res=http.get('api/second?page=1&type=0&sort=1',data=body)
    print(res.json())
def test_xq(token):
    body={
        "id" : 92,
    }
    http=A3mall_login(url='http://10.59.9.14:7003/')
    res=http.get("api/second/view?id=92",data=body)
    print(res.json())
def test_ljzf(token):
    headers={
        "auth-token" : token
    }
    body={
        "id" : 92,
        "type" : 'second',
        "sku_id" : "num",
        "num" : 1,
        "shipping_type" : 1
    }
    http=A3mall_login(url='http://10.59.9.14:7003/')
    res=http.get("api/order/confirm?id=92&type=second&sku_id=&num=1&shipping_type=1",data=body,headers=headers)
    print(res.json())
def test_tjdd(token):
    headers={
        "auth-token" : token
    }
    body={
        "address_id" : 15,
        "bonus_id" : '0',
        "id" : 92,
        "num" : 1,
        "payment" : "balance",
        "remarks" : "",
        "shipping_type" : 1,
        "sku_id" : "num",
        "source" : 1,
        "store_id" : 1,
        "type" : "second",
        "url" : "http://10.59.9.14:7003/wap/pages/cart/confirm?id=92&sku_id=&num=1&type=second"
    }
    http=A3mall_login(url='http://10.59.9.14:7003/')
    res=http.post("api/order/create",data=body,headers=headers)
    print(res.json())
